package cn.edu.xjtu;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Date;

public class CmdTest {
    public static void runCMD(String str) throws Exception {
        Process p = Runtime.getRuntime().exec(str);
        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String readLine = br.readLine();
        while (readLine != null) {
            readLine = br.readLine();
            System.out.println(readLine);
        }
        if (br != null) {
            br.close();
        }
        p.destroy();
        p = null;
    }

    public static void main(String[] args) {
        String str = "cmd /d/s/c C:\\Users\\霍嘉\\AppData\\Roaming\\Typora\\picgo\\win64\\picgo.exe u \"D:\\大三上\\操作系统\\笔记\\01_Introduction\\01_Introduction.assets\\image-20210922124905919.png\"";
        System.out.println(new Date());
        try {
            runCMD(str);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(new Date());
    }
}
